package com.wander.rep.patient;

import java.io.Serializable;
import java.util.ArrayList;

public class Patient implements Serializable {
	
	/**
	 * Generated Serial VErsion
	 */
	private static final long serialVersionUID = -886528319485660L;
	
	private String pName;
	private String pSurname;
	private int id;
	
	private Home pHome;
	private ArrayList<Home> pHomeHistory;
	
	private ActivityLevel pActivityLevel;
	private ArrayList<ActivityLevel> pActivityLevelHistory;
	
	private Location pPattern;
	private ArrayList<Location> pPatternHistory;
	
	private ArrayList<Issue> pIssueHistory;


	public Patient(String pName, String pSurname, int pId, Home pHome) {
		
		this.pName = pName;
		this.pSurname = pSurname;
		this.setId(pId);
		this.pHome = pHome;
		
		pIssueHistory = new ArrayList<Issue>();
		
	}


	public String getpName() {
		return pName;
	}


	public void setpName(String pName) {
		this.pName = pName;
	}


	public String getpSurname() {
		return pSurname;
	}


	public void setpSurname(String pSurname) {
		this.pSurname = pSurname;
	}


	public Home getpHome() {
		return pHome;
	}


	public void setpHome(Home pHome) {
		this.pHome = pHome;
	}


	/*
	 * Weights all elements' Status and provides one ultimate status for patient
	 */
	@SuppressWarnings("unused")
	public Status getStatus() 
	{
		int status = 0;
		boolean isAlert = false;
		
		if(pActivityLevel.getStatus() == Status.ATTENTION)
		{
			status += 1;
		}
		else if(pActivityLevel.getStatus() == Status.ALERT)
		{
			isAlert = true;
		}
		
		if(pHome.gethStatus() == Status.ATTENTION)
		{
			status += 1;
		}
		else if(pHome.gethStatus() == Status.ALERT)
		{
			isAlert = true;
		}
		
		if(pPattern.getlStatus() == Status.ATTENTION)
		{
			status += 1;
		}
		else if(pPattern.getlStatus() == Status.ALERT)
		{
			isAlert = true;
		}
		
		if(!isAlert)
		{
			if(status >= 2)
			{
				return Status.ATTENTION;
			}
			else
			{
				return Status.FINE;
			}
		}
		else
		{
			return Status.ALERT;
		}
		
	}

	public ActivityLevel getpActivityLevel() {
		return pActivityLevel;
	}


	public void setpActivityLevel(ActivityLevel pActivityLevel) {
		this.pActivityLevel = pActivityLevel;
	}


	public Location getpPattern() {
		return pPattern;
	}


	public void setpPattern(Location pPattern) {
		this.pPattern = pPattern;
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public ArrayList<ActivityLevel> getpActivityLevelHistory() {
		return pActivityLevelHistory;
	}


	public void setpActivityLevelHistory(ArrayList<ActivityLevel> pActivityLevelHistory2) {
		this.pActivityLevelHistory = pActivityLevelHistory2;
	}


	public ArrayList<Location> getpPatternHistory() {
		return pPatternHistory;
	}


	public void setpPatternHistory(ArrayList<Location> pPatternHistory) {
		this.pPatternHistory = pPatternHistory;
	}


	public ArrayList<Home> getpHomeHistory() {
		return pHomeHistory;
	}


	public void setpHomeHistory(ArrayList<Home> pHomeHistory) {
		this.pHomeHistory = pHomeHistory;
	}
	
	public void addIssue(Issue issue)
	{
		pIssueHistory.add(issue);
	}
	
	public ArrayList<Issue> getpIssueHistory() 
	{
		return pIssueHistory;
	}
}
